package com.itlaobing.demo.servlet;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.itlaobing.demo.util.Result;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Classname UserDelServlet
 * @Description TODO()
 * @Date 2020/11/14 0014 10:31
 * @Author by Administrator
 * @Version v1.0
 */
@WebServlet("/delete")
public class UserDelServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 接收参数
        String id = req.getParameter("id");
        // 做删除操作

        ObjectMapper mapper = new ObjectMapper();
        String json = mapper.writeValueAsString(Result.ok("删除成功"));

        System.out.println(json);
        // 返回数据 json
        resp.getWriter().write(json);
    }

}
